package com.panshi.modules.service.impl;

import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.panshi.modules.domain.UserNotice;
import com.panshi.modules.domain.UserNoticeRead;
import com.panshi.modules.mapper.UserNoticeMapper;
import com.panshi.modules.service.UserNoticeService;
import com.panshi.vo.ItemQueryUserVo;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserNoticeServiceImpl extends ServiceImpl<UserNoticeMapper, UserNotice> implements UserNoticeService {

    @Override
    public List<UserNotice> findUserNoticeList(ItemQueryUserVo itemQueryVo) {
        return this.baseMapper.findUserNoticeList(itemQueryVo);
    }

    @Override
    public int updateRead(int id) {
        UserNotice userNotice = new UserNotice();
        userNotice.setId(id);
        userNotice.setStatus(1);
        return this.baseMapper.update(userNotice,new UpdateWrapper<UserNotice>().set("status",1).eq("id",userNotice.getId()));
    }

    @Override
    public List<UserNoticeRead> getNoReadCount(int id) {
        return this.baseMapper.getNoReadCount(id);
    }
}
